nmc: build-side merged-mining commitment (PC-prep, build/verify symmetry) - #408
Merged
Conversation
…try) Add nmc::coin::build_mm_commitment(), the build-side inverse of scan_mm_commitment(): emit the canonical merged-mining commitment payload a parent (BTC) coinbase scriptSig must carry for an embedded NMC aux chain. Byte layout matches the scanner the verifier already runs bit-for-bit: MM_HEADER_MAGIC(4) | chain_merkle_root REVERSED(32) | size_le32 | nonce_le32, size = 2^chain_height, slot = aux_expected_index(nonce, chain_id, height). PB-independent (no NameOp/mempool dependency); overlaps PD dual-target. NMC-local per the coin fence (std + core types only); btc tree READ-ONLY. +3 KATs in nmc_auxpow_merkle_test (already allowlisted, no build.yml change): round-trip emit->scan MATCH at the expected slot; explicit byte-layout pin; tampered root/slot -> MISMATCH. 77->80 tests, all green.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
nmc::coin::build_mm_commitment()— the build-side inverse of the existingscan_mm_commitment()verifier. Emits the canonical merged-mining commitment payload a parent (BTC) coinbase scriptSig must carry so an embedded NMC aux chain is provable.Byte layout is bit-for-bit what the scanner walks:
MM_HEADER_MAGIC(4) | chain_merkle_root REVERSED(32) | size_le32 | nonce_le32, size = 2^chain_height, slot =aux_expected_index(nonce, chain_id, height).Why
Closes the build/verify symmetry gap: the verify side (slot derivation, scanner, aux_merkle_root) already exists; the build side that PD wires into the dual-target parent coinbase did not. PB-independent (no NameOp/mempool dependency) — cut off master per slice-base rule, NOT stacked on #402.
Tests
+3 KATs in
nmc_auxpow_merkle_test(already allowlisted — no build.yml change, no #137 NOT_BUILT trap): round-trip emit->scan MATCH at the expected slot; explicit byte-layout pin; tampered root/slot -> MISMATCH. 77->80, all green locally.Fence
src/impl/nmc/only (header_chain.hpp + auxpow_merkle_test.cpp). NMC-local, std + core types only; btc tree consumed READ-ONLY; no core/shared/other-coin edits.